<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<script>

Array.dim = function(dimension, initial) {
    var a = [], i;
    for( i = 0; i < dimension; i += 1) {
        a[i] = initial;
    }
    return a;
};

var matrix = [ 
     [0, 1, 2], 
     [3, 4, 5], 
     [6, 7, 8] 
]; 
matrix[2][1]	//7

for( i = 0; i < n; i += 1) { 
    my_array[i] = [];
}


Array.matrix = function(m, n, initial) {
    var a, i, j, mat = [];
    for( i = 0; i < m; i += 1) {
        a = [];
        for( j = 0; j < n; j += 1) {
            a[j] = initial;
        }
        mat[i] = a;
    }
    return mat;
};

var myMatrix = Array.matrix(5, 5, 0); 
document.writeln(myMatrix[2][4]); // 0


</script>
</head>
<body>




</body>
</html>
